<?php
$vals = array(
    'img_path' => './captcha/',
    'img_url' => base_url().'captcha/'
    );

$cap = create_captcha($vals);

$data = array(
    'captcha_time' => $cap['time'],
    'ip_address' => $this->input->ip_address(),
    'word' => $cap['word']
    );

$query = $this->db->insert_string('captcha', $data);
$this->db->query($query);

?>

<form action="<? echo base_url()?>contacto/capcha_validate" method="POST">
    <table>
        <tr><td><?php echo $cap['image']; ?></td></tr>
        <tr><td><input type="text" name="captcha" value="" /></td></tr>
        <tr><td><input type="submit" value="enviar" /></td></tr>
    </table>
</form>